<%@page import="java.text.DateFormat"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%--
    Document   : ListarClientes
    Created on : may 18, 2013, 10:29:43 p.m.
    Author     : Hcornejo
--%>

<%@page import="crm.benedicto.beans.Prospecto"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Consulta de Prospectos</title>

        <link rel="stylesheet" href="rcr_css/css/smoothness/jquery-ui-1.10.3.custom.css" />
        <link rel="stylesheet" href="Estilos/Estilos.css" />
        <script language="javascript" src="rcr_css/js/jquery-1.9.1.js"></script>
        <script language="javascript" src="rcr_css/js/jquery-ui.js"></script>
        <script>
            /*
             Listado Operaciones :
             1--> Busqueda
             2--> Eliminar 
             3--> Insertar
             4--> RedireccionaActualizar
             5--> Actualizar
             */
            function Salir() {
                window.location = "Default.jsp";
                return false;
            }
            function ListarProspecto()
            {
                var context = "<%= request.getContextPath()%>";
                document.getElementById("_Operacion").value = 1;
                document.form1.action = context + "/ServletProspecto";
                document.form1.method = "POST";
                document.form1.submit();
            }
            function Eliminar(IdProspecto)
            {
                var context = "<%= request.getContextPath()%>";
                document.getElementById("_Operacion").value = 2;
                document.getElementById("_CodigoProspecto").value = IdProspecto;
                document.form1.action = context + "/ServletProspecto";
                document.form1.method = "POST";
                document.form1.submit();
            }
            function Ingresar()
            {
                window.location = "MantenimientoProspecto.jsp";
                return false;
            }
            function Actualizar(IdProspecto)
            {
                var context = "<%= request.getContextPath()%>";
                document.getElementById("_Operacion").value = 4;
                document.getElementById("_CodigoProspecto").value = IdProspecto;
                document.form1.action = context + "/ServletProspecto";
                document.form1.method = "POST";
                document.form1.submit();
            }
        </script>

    </head>
    <body>
        <div name="page" class="page">
            <form name="form1" action="" method="POST" >
                </br>
                <%@include file="/Menu.jsp" %>
                <p></p>
                <h1>Listado de Prospectos</h1>
                <table class="stlPanelBusqueda">
                    <tr>
                        <td>DNI</td>
                        <td>:</td>
                        <td><input name="tbDni" type="text" maxlength="10" width="80px"></td>
                        <td></td>
                        <td>Nombres</td>
                        <td>:</td>
                        <td><input name="tbNombres" type="text" maxlength="10" width="80px"></td>
                    </tr>
                    <tr>
                        <td>Apellido Paterno</td>
                        <td>:</td>
                        <td><input name="tbApellidoPaterno" type="text" maxlength="10" width="80px">
                        <td></td>
                        <td>Apellido Materno</td>
                        <td>:</td>
                        <td><input name="tbApellidoMaterno" type="text" maxlength="10" width="80px"></td>
                        <td></td>
                        <td>Fecha de Contacto</td>
                        <td>:</td>
                        <td><input id="tbFechaContacto" name="tbFechaContacto" type="text" maxlength="10" width="80px"></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td style=" text-align: right"><input type="submit" value="Buscar" name="btnBuscar" class="stlbutton" onclick="ListarProspecto();"></td>
                    </tr>

                </table>
                <p></p>
                <div style="width: 100%; height: 245px;border: 1px solid #999999;">
                    <table name="tblRegistros" style=" width:100%;" >
                        <tr>     
                            <td class="stlDataGridFixedHeader" style=" width: 20px;">Eliminar</td>
                            <td class="stlDataGridFixedHeader" style=" width: 20px;">Modificar</td>
                            <td class="stlDataGridFixedHeader" style=" width: 120px;">DNI</td>
                            <td class="stlDataGridFixedHeader" style=" width: 120px;">Nombres</td>
                            <td class="stlDataGridFixedHeader" style=" width: 420px;">Apellido Paterno</td>
                            <td class="stlDataGridFixedHeader" style=" width: 420px;">Apellidos Materno</td>
                            <td class="stlDataGridFixedHeader" style=" width: 220px;">Email</td>
                            <td class="stlDataGridFixedHeader" style=" width: 120px;">Telefono</td>
                            <td class="stlDataGridFixedHeader" style=" width: 120px;">Celular</td>
                            <td class="stlDataGridFixedHeader" style=" width: 220px;">Fecha de Contacto</td>
                        </tr>
                        <%
                            List<Prospecto> lsProspecto = null;
                            if (request.getAttribute("listaProspectos") != null) {
                                lsProspecto = (List<Prospecto>) request.getAttribute("listaProspectos");

                                for (int i = 0; i < lsProspecto.size(); i++) {
                                    Prospecto pro = lsProspecto.get(i);
                                    
                        %>
                        <tr>
                            <td style=" width: 20px; text-align: center;"><img name="imgEliminar" style=" cursor: pointer" src="imagenes/ico_Borrar.gif" onclick="Eliminar(<%= pro.getCodigo()%>);"></td>
                            <td style=" width: 20px; text-align: center;"><img name="imgActualizar" style=" cursor: pointer" src="imagenes/ico_Edita.gif" onclick="Actualizar(<%= pro.getCodigo()%>);"></td>
                            <td style="text-align: center;"> <%= pro.getDni() %> </td>
                            <td style="text-align: center;"><%= pro.getNombre() %></td>
                            <td style="text-align: center;"><%= pro.getApellidopaterno() %></td>
                            <td style="text-align: center;"><%= pro.getApellidomaterno() %></td>
                            <td style="text-align: center;"><%= pro.getEmail() %></td>
                            <td style="text-align: center;"><%= pro.getTelefono() %></td>
                            <td style="text-align: center;"><%= pro.getCelular() %></td>
                            <td style="text-align: center;"><%= String.format(pro.getFechacontacto(),"dd/mm/yyyy")%></td>
                        </tr>
                     <%} %>
                     <% } %>
                    </table>
                        
                </div>
                <p></p>
                <div class="stlLinea" ></div>
                <p style=" text-align: right;">
                    <input name="btnIngresar" type="button" value="Ingresar" class="stlbutton" onclick="Ingresar();" />
                    <input name="btnSalir" type="button" value="Salir" class="stlbutton" onclick="Salir();" />
                    <input type="hidden" id="_Operacion" value="" name="_Operacion">
                    <input type="hidden" id="_CodigoProspecto" value="" name="_CodigoProspecto">
                </p>
            </form>
        </div>
    </body>
</html>
